using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

using FreeFlow;
using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for FieldUsageControl.
	/// </summary>
	public class FieldUsageControl : System.Windows.Forms.UserControl
	{
    private System.Windows.Forms.ListView fieldUsageValueList;
    private System.Windows.Forms.ColumnHeader columnHeader1;
    private System.Windows.Forms.ColumnHeader columnHeader2;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public FieldUsageControl()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
      this.fieldUsageValueList = new System.Windows.Forms.ListView();
      this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
      this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
      this.SuspendLayout();
      // 
      // fieldUsageValueList
      // 
      this.fieldUsageValueList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                                                                                          this.columnHeader1,
                                                                                          this.columnHeader2});
      this.fieldUsageValueList.Dock = System.Windows.Forms.DockStyle.Fill;
      this.fieldUsageValueList.FullRowSelect = true;
      this.fieldUsageValueList.Location = new System.Drawing.Point(0, 0);
      this.fieldUsageValueList.Name = "fieldUsageValueList";
      this.fieldUsageValueList.Size = new System.Drawing.Size(440, 150);
      this.fieldUsageValueList.TabIndex = 35;
      this.fieldUsageValueList.View = System.Windows.Forms.View.Details;
      // 
      // columnHeader1
      // 
      this.columnHeader1.Text = "Field";
      this.columnHeader1.Width = 200;
      // 
      // columnHeader2
      // 
      this.columnHeader2.Text = "Usage";
      this.columnHeader2.Width = 200;
      // 
      // FieldUsageControl
      // 
      this.Controls.Add(this.fieldUsageValueList);
      this.Name = "FieldUsageControl";
      this.Size = new System.Drawing.Size(440, 150);
      this.ResumeLayout(false);

    }
		#endregion

    public void LoadFieldUsage(FieldUsageCollection fieldUsage)
    {
      foreach (DictionaryEntry entry in fieldUsage)
      {
        ListViewItem item = new ListViewItem(new string[] {entry.Key.ToString(), 
          EnumDescription.GetDescription((Enum)entry.Value)});
        fieldUsageValueList.Items.Add(item);
      }
    }
	}
}
